<template>
  <div class="page-header-index-wide">
    <div >
      <a-row :gutter="24">
        <a-col :sm="24" :md="12" :style="{ width: '16.5%' }" v-for="(item,index) in dataTotal" :key="index">
          <a-card>
            <div style="display: flex; justify-content: space-around; align-items: center; height: 119px">
              <div class="iconBox">
                <div class="iconBg"></div>
                <img :src="item.icon" />
              </div>
              <div style="text-align: center">
<!--                <span style="font-size: 30px; color: #3682f8; font-weight: bold; line-height: 50px"> {{item.num == null ? 0 : item.num}} </span>-->
                <span :style="{color:item.color,fontSize:30+'px',fontWeight:'bold',lineHeight:50+'px'}"> {{item.num == null ? 0 : item.num}} </span>
                <div style="margin-top: 0.5rem">{{item.name}}</div>
              </div>
            </div>
          </a-card>
        </a-col>
      </a-row>
    </div>
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="最近一周访问量统计" :style="{ marginTop: '24px' }">
          <a-row>
            <a-col :span="6">
              <head-info title="今日IP" :content="loginfo.todayIp"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="environment" style="font-size: 24px"  />
              </a-spin>
            </a-col>
            <a-col :span="6">
              <head-info title="今日访问" :content="loginfo.todayVisitCount"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="team" style="font-size: 24px"  />
              </a-spin>
            </a-col>
            <a-col :span="6">
              <head-info title="总访问量" :content="loginfo.totalVisitCount"></head-info>
            </a-col>
            <a-col :span="2">
              <a-spin class='circle-cust'>
                <a-icon slot="indicator" type="rise" style="font-size: 24px"  />
              </a-spin>
            </a-col>
          </a-row>
          <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
        </a-card>
      </a-col>
    </a-row>
  </div>
</template>

<script>
  import ChartCard from '@/components/ChartCard'
  import ACol from "ant-design-vue/es/grid/Col"
  import ATooltip from "ant-design-vue/es/tooltip/Tooltip"
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'

  import Trend from '@/components/Trend'
  import { getLoginfo,getVisitInfo } from '@/api/api'

  import { httpAction, getAction } from '@/api/manage'

  const rankList = []
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i+1) + ' 号店',
      total: 1234.56 - i * 100
    })
  }
  const barData = []
  for (let i = 0; i < 12; i += 1) {
    barData.push({
      x: `${i + 1}月`,
      y: Math.floor(Math.random() * 1000) + 200
    })
  }
  export default {
    name: "IndexChart",
    components: {
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      Trend,
      LineChartMultid,
      HeadInfo
    },
    data() {
      return {
        dataTotal:[],
        loading: true,
        center: null,
        rankList,
        barData,
        loginfo:{},
        visitFields:['ip','visit'],
        visitInfo:[],
        indicator: <a-icon type="loading" style="font-size: 24px" spin />
      }
    },
    created() {
      this.dataStatistics()
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
      this.initLogInfo();
    },
    methods: {
      dataStatistics(){
        getAction("/gqHealth/gqCardManager/statisticsData").then(res=>{
          if(res.code == 200){
            let data = res.result
            this.dataTotal.push(
              {
                name:"激活卡数",
                icon:require('@/assets/imageIcon/activation_card.svg'),
                num:data.activationTotal,
                color: "#45c069",
              },
              {
                name:"未激活卡数",
                icon:require("@/assets/imageIcon/activation_no_card.svg"),
                num:data.notActiveTotal,
                color: "#ef3a18",
              },
              {
                name:"体检总数",
                icon:require("@/assets/imageIcon/checkup_icon.svg"),
                num:data.checkTotal,
                color: "#a886f6",
              },
              {
                name:"医院总数",
                icon:require("@/assets/imageIcon/hot_icon.svg"),
                num:data.hospitalTotal,
                color: "#45c069",
              },
              {
                name:"用户总数",
                icon:require("@/assets/imageIcon/user_icon.svg"),
                num:data.userTotal,
                color: "#f4b03e",
              },
              {
                name:"实名总数",
                icon:require("@/assets/imageIcon/user_real_icon.svg"),
                num:data.realNameTotal,
                color: "#1a91ff",
              }
            )
          }
          console.log(this.dataTotal,"123456")
        })
      },
      initLogInfo () {
        getLoginfo(null).then((res)=>{
          if(res.success){
            Object.keys(res.result).forEach(key=>{
              res.result[key] =res.result[key]+""
            })
            this.loginfo = res.result;
          }
        })
        getVisitInfo().then(res=>{
          if(res.success){
             this.visitInfo = res.result;
           }
         })
      },
    }
  }
</script>

<style lang="less" scoped>
.iconBox {
  position: relative;
  height: 4.2rem;
  width: 4.2rem;
  .iconBg {
    height: 100%;
    width: 100%;
    background: rgba(24, 143, 253, 0.8);
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    margin: 0 auto;
    -webkit-filter: blur(0.2rem);
    -ms-filter: blur(0.1rem);
    filter: blur(0.1rem);
  }
  img {
    width: 3.5rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

.rightCard {
  display: flex;
  justify-content: space-between;
  padding-right: 2rem;
  font-size: 16px;
  margin: 1rem 0;
  padding-left: 1rem;
}
.rightText {
  font-weight: bold;
  font-size: 16px;
  //background: #00ff80;
}
.chartCard_img {
  height: 30%;
  width: 30%;
  img {
    height: 100%;
    width: 100%;
    border-radius: 100%;
  }
}
.extra-wrapper {
  line-height: 55px;
  padding-right: 24px;

  .extra-item {
    display: inline-block;
    margin-right: 24px;

    a {
      margin-left: 24px;
    }
  }
}

.item-group {
  padding: 20px 0 8px 24px;
  font-size: 0;

  a {
    color: rgba(0, 0, 0, 0.65);
    display: inline-block;
    font-size: 14px;
    margin-bottom: 13px;
    width: 25%;
  }
}

.item-group {
  .more-btn {
    margin-bottom: 13px;
    text-align: center;
  }
}

.list-content-item {
  color: rgba(0, 0, 0, 0.45);
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
}

@media only screen and (min-width: 1600px) {
  .list-content-item {
    margin-left: 60px;
  }
}

@media only screen and (max-width: 1300px) {
  .list-content-item {
    margin-left: 20px;
  }

  .width-hidden4 {
    display: none;
  }
}

.list-content-item {
  span {
    line-height: 20px;
  }
}

.list-content-item {
  p {
    margin-top: 4px;
    margin-bottom: 0;
    line-height: 22px;
  }
}

.anty-list-cust {
  .ant-list-item-meta {
    flex: 0.3 !important;
  }
}

.anty-list-cust {
  .ant-list-item-content {
    flex: 1 !important;
    justify-content: flex-start !important;
    margin-left: 20px;
  }
}

  .circle-cust{
    position: relative;
    top: 28px;
    left: -100%;
  }
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }

  /* 首页访问量统计 */
  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, .45);
      display: inline-block;
      font-size: .95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }
    p {
      line-height: 42px;
      margin: 0;
      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  }
</style>